package vis.app.components;

import java.awt.BorderLayout;

import javax.swing.JPanel;

import vis.items.visualItem.AbstractSketch;

public class PanelDisplay extends JPanel implements IPanelComponent {

	private static final long serialVersionUID = -813812416740756653L;

	@Override
	public void init() {
		this.setLayout(new BorderLayout());
	}

	public void initForSketch(AbstractSketch sketch) {
		this.removeAll();
		this.add(sketch, BorderLayout.CENTER);
	}

	public void runSketch(AbstractSketch sketch) {
		AbstractSketch currentSketch = (AbstractSketch) this.getComponent(0);
		if (currentSketch.matchSketch(sketch)) {
			currentSketch.init();
		} else {
			System.err.println("ERROR WHILE GET SKETCH FROM DISPLAY PANEL");
		}
	}

}
